﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace iTunesUpdater
{
	public partial class ucItemList : UserControl
	{
		public ListBox.ObjectCollection Items {
			get {
				return listBox1.Items;
			}
		}

		public string PromptText {
			get;
			set;
		}

		public string PromptTitle {
			get;
			set;
		}

		public ucItemList() {
			InitializeComponent();
		}

		private void bAdd_Click(object sender, EventArgs e) {
			string s = "";
			EditString(ref s);
			if (s != "")
				listBox1.Items.Add(s);
		}

		private void EditString(ref string s) {
			s = Microsoft.VisualBasic.Interaction.InputBox(PromptText, PromptTitle, s, 0, 0);
		}

		private void bEdit_Click(object sender, EventArgs e) {
			if (listBox1.SelectedItem != null) {
				int i = listBox1.SelectedIndex;
				string s = (string)listBox1.SelectedItem;
				EditString(ref s);
				if (s != "") {
					listBox1.Items.RemoveAt(i);
					listBox1.Items.Insert(i, s);
				}
			}
		}

    private void bDelete_Click(object sender, EventArgs e) {
      if (listBox1.SelectedItem != null)
        listBox1.Items.RemoveAt(listBox1.SelectedIndex);
    }


	}
}
